//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "Australia.h"
using namespace Cephei::QL::Times::Calendars;
#include <gen/QL/Times/Period.h>
#include <gen/QL/Times/Calendar.h>
using namespace Cephei::QL::Times;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Times::Calendars::CAustralia::CAustralia () : CCalendar(CAustralia::typeid)
{
    try
    {
#ifdef HANDLE
        _phAustralia = NULL;
#endif
        _ppAustralia = new boost::shared_ptr<QuantLib::Australia> (new QuantLib::Australia ( ));
        SetCalendar (boost::dynamic_pointer_cast<QuantLib::Calendar> (*_ppAustralia));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::Calendars::CAustralia::CAustralia (boost::shared_ptr<QuantLib::Australia>& childNative, Object^ owner) : CCalendar(CAustralia::typeid)
{
#ifdef HANDLE
	_phAustralia = NULL;
#endif
	_ppAustralia = &childNative;
    _ppCalendar = new boost::shared_ptr<QuantLib::Calendar> (boost::dynamic_pointer_cast<QuantLib::Calendar> (*_ppAustralia));
}
Cephei::QL::Times::Calendars::CAustralia::CAustralia (QuantLib::Australia& childNative, Object^ owner) : CCalendar(CAustralia::typeid)
{
#ifdef HANDLE
	_phAustralia = NULL;
#endif
	_ppAustralia = new boost::shared_ptr<QuantLib::Australia> (&childNative);
    _ppCalendar = new boost::shared_ptr<QuantLib::Calendar> (boost::dynamic_pointer_cast<QuantLib::Calendar> (*_ppAustralia));
    _AustraliaOwner = owner;
    _CalendarOwner = owner;
}

Cephei::QL::Times::Calendars::CAustralia::CAustralia (CAustralia^ copy) : CCalendar(CAustralia::typeid)
{
#ifdef HANDLE
	_phAustralia = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppAustralia = new boost::shared_ptr<QuantLib::Australia> (copy->GetShared());
        _ppCalendar = new boost::shared_ptr<QuantLib::Calendar> (boost::dynamic_pointer_cast<QuantLib::Calendar> (*_ppAustralia));
    }
}
Cephei::QL::Times::Calendars::CAustralia::CAustralia (PLATFORM::Type^ t) : CCalendar(CAustralia::typeid)
{
#ifdef HANDLE
	_phAustralia = NULL;
#endif
	if (!t->IsSubclassOf(CAustralia::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Times::Calendars::CAustralia::CAustralia (QuantLib::Handle<QuantLib::Australia>& childNative, Object^ owner)  : CCalendar(CAustralia::typeid)
{
	_phAustralia = &childNative;
	_ppAustralia = &static_cast<boost::shared_ptr<QuantLib::Australia>>(childNative.currentLink());
    _ppCalendar = new boost::shared_ptr<QuantLib::Calendar> (boost::dynamic_pointer_cast<QuantLib::Calendar> (*_ppAustralia));
    _AustraliaOwner = owner;
}
Cephei::QL::Times::Calendars::CAustralia::CAustralia (QuantLib::Handle<QuantLib::Australia> childNative)  : CCalendar(CAustralia::typeid)
{
	_phAustralia = &childNative;
	_ppAustralia = &static_cast<boost::shared_ptr<QuantLib::Australia>>(childNative.currentLink());
    _ppCalendar = new boost::shared_ptr<QuantLib::Calendar> (boost::dynamic_pointer_cast<QuantLib::Calendar> (*_ppAustralia));
}
#endif
#ifdef STRUCT
Cephei::QL::Times::Calendars::CAustralia::CAustralia (QuantLib::Australia childNative)  : CCalendar(CAustralia::typeid)
{
#ifdef HANDLE
	_phAustralia = NULL;
#endif
	_ppAustralia = new boost::shared_ptr<QuantLib::Australia> (new QuantLib::Australia (childNative));
    _ppCalendar = new boost::shared_ptr<QuantLib::Calendar> (boost::dynamic_pointer_cast<QuantLib::Calendar> (*_ppAustralia));
}
#endif

Cephei::QL::Times::Calendars::CAustralia::~CAustralia ()
{
    if (_ppAustralia != NULL)
    {
	    delete _ppAustralia;
        _ppAustralia = NULL;
    }
}
Cephei::QL::Times::Calendars::CAustralia::!CAustralia ()
{
    if (_ppAustralia != NULL)
    {
	    delete _ppAustralia;
    }
}
QuantLib::Australia& Cephei::QL::Times::Calendars::CAustralia::GetReference ()
{
    if (_ppAustralia == NULL) throw REFNEW NativeNullException ();
	return **_ppAustralia;
}
boost::shared_ptr<QuantLib::Australia>& Cephei::QL::Times::Calendars::CAustralia::GetShared ()
{
    if (_ppAustralia == NULL) throw REFNEW NativeNullException ();
	return *_ppAustralia;
}
QuantLib::Australia* Cephei::QL::Times::Calendars::CAustralia::GetPointer ()
{
    if (_ppAustralia == NULL) throw REFNEW NativeNullException ();
	return &**_ppAustralia;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::Australia>& Cephei::QL::Times::Calendars::CAustralia::GetHandle ()
{
	if (_phAustralia == NULL)
	{
		_phAustralia = new Handle<QuantLib::Australia> (*_ppAustralia);
	}
	return *_phAustralia;
}
#endif
bool Cephei::QL::Times::Calendars::CAustralia::HasNative () 
{
	return (_ppAustralia != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Times::Calendars::IAustralia^ Cephei::QL::Times::Calendars::CAustralia_Factory::Create ()
{
    return REFNEW CAustralia ();
}
